from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime

from src.models.transaction import TransactionType, TransactionStatus

# 交易记录基础信息
class TransactionBase(BaseModel):
    trade_id: int
    amount: float = Field(gt=0)
    type: TransactionType
    description: Optional[str] = None


# 创建交易记录请求
class TransactionCreate(TransactionBase):
    pass


# 交易记录响应
class TransactionResponse(BaseModel):
    id: int
    trade_id: int
    amount: float
    type: TransactionType
    status: TransactionStatus
    description: Optional[str] = None
    created_at: datetime
    updated_at: datetime
    completed_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True